// 数组解构允许我们按照一一对应的关系从数组中提取值, 然后将值赋值给变量
let arr = [1, 2, 4]
let [a, b, c] = arr;
console.log(a)
console.log(b)
console.log(c)


// 对象解构允许我们使用变量的名字匹配的对象
let person = {name: 'zhangsan', age: 20};

let {name, age} = person;

console.log(name)   // zhangsan
console.log(age)    // 20

// newName, newAge 属于别名
let {name: newName, age: newAge} = person;
console.log(newName)
console.log(newAge)


console.log(foo); // 输出undefined
var foo = 2;


